﻿using DocumentFormat.OpenXml.Office2010.Excel;
using ERP.ERPSystem.ProductionSystem;
using ERP.ERPSystem.ProductionSystem.Dto;
using ERP.Team.ProductionSystem;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ERP.Web.Controllers.ProductionSystem
{
    /// <summary>
    /// 生产系统-设备管理-点检保养计划-xzc
    /// </summary>
    public class MaintenanceController : Controller
    {
        private readonly IMaintenanceSerivces _maintenanceSerivces;
        public MaintenanceController(IMaintenanceSerivces maintenanceSerivces)
        {
            _maintenanceSerivces = maintenanceSerivces;
        }

        /// <summary>
        /// 点检保养计划视图
        /// </summary>
        /// <returns></returns>
        public IActionResult MaintenanceView()
        {
            return View();
        }
        /// <summary>
        /// 新增点检保养计划视图
        /// </summary>
        /// <returns></returns>
        public IActionResult AddMaintenanceView()
        {
            return View();
        }
        /// <summary>
        /// 更新点检保养计划视图
        /// </summary>
        /// <returns></returns>
        public IActionResult UpdateMaintenanceView()
        {
            return View();
        }
        /// <summary>
        /// 新增点检保养计划
        /// </summary>
        /// <param name="maintenancedto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddMaintenance(MaintenanceDto maintenancedto)
        {
            var i = await _maintenanceSerivces.AddMaintenance(maintenancedto);
            return i;
        }
        /// <summary>
        /// 更改点检保养计划
        /// </summary>
        /// <param name="maintenancedto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateMaintenance(MaintenanceDto maintenancedto)
        {
            var result = await _maintenanceSerivces.UpdateMaintenance(maintenancedto);
            return result;
        }
        /// <summary>
        /// 通过id查询到对应的点检保养计划
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Maintenance>> FindMaintenance(int id)
        {
            var i = await _maintenanceSerivces.FindMaintenance(id);
            return i;
        }
        /// <summary>
        /// 删除点检保养计划
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteMaintenance(int id)
        {
            await _maintenanceSerivces.DeleteMaintenance(id);
        }
        /// <summary>
        /// 查询点检保养计划
        /// </summary>
        /// <param name="getmaintenancedto"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Maintenance>> GetMaintenance(GetMaintenanceDto getmaintenancedto)
        {
            var i = await _maintenanceSerivces.GetMaintenance(getmaintenancedto);
            return i;
        }
        /// <summary>
        /// 批量删除点检保养计划
        /// </summary>
        /// <param name="ids">要删除的ID列表</param>
        /// <returns></returns>
        [HttpPost]
        public async Task BatchDeleteMaintenance([FromBody]List<int> ids)
        {
            await _maintenanceSerivces.BatchDeleteMaintenance(ids);
        }
    }
}
